package com.msos.servlet.moreCredit;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;

@WebServlet(urlPatterns = "/morecredit")
public class MoreCreditServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String action = req.getParameter("action");
        if ("page".equals(action)){
            //说明是来请求页面的
            req.getRequestDispatcher("/WEB-LNF/jsp/MoreCredit/MoreCredit.jsp").forward(req,resp);
        }else if ("data".equals(action)){
            String sas = req.getParameter("金额");
            String pattern = "\\+(\\.\\d{1,2})?";//正则表达式判断
            boolean isMatch = Pattern.matches(pattern,sas);
            //说明是来请求jsona数据的
            if(!isMatch){
                System.out.println("输入的金额有误，请重新输入...");
            }
        }

    }
}
